﻿<%@ Page Language="C#" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace=" System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="TarreOA.TarreOAModels" %>
<%@ Import Namespace="TarreOA.TarreOABLL" %>

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            User curLoginUser = (User)Session["user"];
            this.LblName.Text = curLoginUser.LoginName + "&nbsp;&nbsp;" + DateTime.Now.ToShortDateString().Replace("-", "/");
            if (Request.QueryString.Get("ca_id") != null)
            {
                int caid = int.Parse(Request.QueryString.Get("ca_id"));
                UserCalendarArrangetbService ucatbService = new UserCalendarArrangetbService();
                UserCalendarArrangetb ucatb = ucatbService.findByCaId(caid);
                this.LbtIKnow.Attributes.Add("ca_id", caid.ToString());
                this.LbtDel.Attributes.Add("ca_id", caid.ToString());
                if (ucatb != null)
                {
                    this.LblTitle.Text = ucatb.CalendarArrangeTitle;
                    this.TxtContent.Text = ucatb.CalendarArrangeContent; 
                } 
            }   
        }  
    }

    protected void LbtIKnow_Click(object sender, EventArgs e)
    {
        int caid = int.Parse(((LinkButton)sender).Attributes["ca_id"]);
        User curLoginUser = (User)Session["user"];
        CalendarArrangeInfos cainfos = CalendarArrangeInfos.instance();
        List<UserCalendarArrangetb> list = (List<UserCalendarArrangetb>)cainfos.Cainfos[curLoginUser.LoginName];
        if (list.Count > 0)
        {
            for (int i = 0; i < list.Count; i++)
            {
                UserCalendarArrangetb ucatb = (UserCalendarArrangetb)list[i];
                if (ucatb.CalendarArrangeId == caid)
                {
                    list.Remove(ucatb);
                    i--; 
                } 
            }
            cainfos.Cainfos[curLoginUser.LoginName] = list;
        }
        ScriptManager.RegisterClientScriptBlock(Page, GetType(), "", "window.close();", true); 
    }

    protected void LbtDel_Click(object sender, EventArgs e)
    {
        int caid = int.Parse(((LinkButton)sender).Attributes["ca_id"]);
        UserCalendarArrangetbService ucatbService = new UserCalendarArrangetbService();
        ucatbService.delCalendarArrangeInfoById(caid);
        ScriptManager.RegisterClientScriptBlock(Page, GetType(), "", "window.close();", true);  
    }
    
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>日程查看</title>
    <script type="text/javascript" src="../js/CalendarArrange.js"></script>
</head>
<body onload="myTime()" leftmargin="0" topmargin="0" bgcolor="#EEEEEE">
    <form id="form1" runat="server">
    <div>
        <table cellpadding="0" cellspacing="0" class="TableBlock" style="width: 100%;font-size:12px">
            <tr>
                <td>
                    <table border="0" cellpadding="0" cellspacing="0" class="small" width="100%">
                        <tr class="TableHeader">
                            <td background="../User/CSS/Snap1.jpg" style="height:30px">
                                <img id="imgAvatar" align="absMiddle" src="../images/calendar_append.gif" style="border-top-width: 0px;
                                    border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" /><b> 日程安排</b>
                            </td>
                            <td align="right" background="../User/CSS/Snap1.jpg" class="small">
                            <font style="font-size:14px">
                                本窗口<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="Smaller" ForeColor="Purple"></asp:Label><span id="TimeShow" style="font-weight: bold;
                                    color: #ff0000"></span> 秒后关闭</font>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr class="TableData">
                <td>
                    <table border="0" cellpadding="1" cellspacing="1" style="width: 100%" bgcolor="black">
                        <tr bgcolor="white" height="25px">
                            <td style="">
                                <asp:Label ID="LblName" runat="server" Width="693px"></asp:Label></td>
                        </tr>
                        <tr height="70" valign="top" bgcolor="white">
                            <td>
                                <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Smaller" Text="标题："></asp:Label>
                                <asp:Label ID="LblTitle" runat="server" Width="643px"></asp:Label><br />
                                <asp:TextBox ID="TxtContent" runat="server" Height="132px" ReadOnly="True" TextMode="MultiLine"
                                    Width="100%"></asp:TextBox></td>
                        </tr>
                        <tr bgcolor="white">
                            <td background="../User/CSS/Snap1.jpg" style="height: 30px">
                                <div align="right">
                                    <asp:LinkButton ID="LbtIKnow" runat="server" OnClick="LbtIKnow_Click">我知道了</asp:LinkButton>&nbsp; &nbsp; &nbsp;<asp:LinkButton ID="LbtDel" runat="server" OnClick="LbtDel_Click">删除</asp:LinkButton></div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>
